const fse = require('fs-extra');
const path = require('path');

//驼峰转烤串命名
function toKebabCase(name) {
  let newName = name.replace(/([A-Z])/g, "-$1").toLowerCase();
  return newName.startsWith('-') ? newName.slice(1) : newName;
}

//判断是否位于根目录
async function isRootFolder() {
  return await fse.pathExists(path.resolve(process.cwd(), 'package.json'));
}

module.exports = {
  toKebabCase,
  isRootFolder
}